package com.invengo.module_robot.data.entity;

import android.text.TextUtils;

import java.util.List;

public class TempBookBean {
    private String bookName;
    private String image="";
    private String publisher;
    private String pubDate;
    private String isbn;
    private String author;
    private String remark;
    private List<String> location;

    public void analyzePopularBook(PopularBean bean){
        this.bookName = bean.getTitle();
        this.isbn = bean.getIsbn();
        if (bean.getDoubanBook() != null) {
            this.image= bean.getDoubanBook().getImage();
            StringBuffer sb = new StringBuffer();
            if (bean.getDoubanBook().getAuthor() != null) {
                for (String author : bean.getDoubanBook().getAuthor()) {
                    if (!TextUtils.isEmpty(sb))
                        sb.append("/");
                    sb.append(author);
                }
                this.author = sb.toString();
            }
            if (!TextUtils.isEmpty(bean.getDoubanBook().getPublisher())) {
                this.publisher = bean.getDoubanBook().getPublisher();
            }
            if (!TextUtils.isEmpty(bean.getDoubanBook().getPubdate())) {
                this.pubDate = bean.getDoubanBook().getPubdate();
            }
            this.remark = bean.getDoubanBook().getSummary();
        }else{
            this.author = "佚名";
        }
    }
    public void analyzeSearchBean(SearchBean.OneItemsDTO item) {
        try {
            this.bookName = item.getBookInfo().getTitle();
            this.publisher= item.getBookInfo().getPublisher();
            this.author = TextUtils.isEmpty(item.getBookInfo().getAuthor())?"佚名":item.getBookInfo().getAuthor();
            this.pubDate = item.getBookInfo().getPubDate();
            this.isbn = item.getBookInfo().getIsbn();

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
//        this.author = item.getBookInfo().getAuthor()
    }

    public String getIsbn() {
        return isbn;
    }

    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getPublisher() {
        return publisher;
    }

    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }

    public String getPubDate() {
        return pubDate;
    }

    public void setPubDate(String pubDate) {
        this.pubDate = pubDate;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public List<String> getLocation() {
        return location;
    }

    public void setLocation(List<String> location) {
        this.location = location;
    }


}
